$(function(){
	$(".player-control").on("click",function(){
		if($(this).hasClass('play-click')) {
			$(this).removeClass('play-click').addClass('pause-click');
			console.log(musicPlaying[0]);
			musicPlaying[0].play();
		} else {
			$(this).removeClass('pause-click').addClass('play-click');
			musicPlaying[0].pause();
		}
	})

	musicPlaying[0].oncanplay =  function(){
		var time = getTime(this.duration);
		$(".totalPlayMusicTime").text(time);
		var music = JSON.parse(localStorage.getItem("music"));
		$(".currentPlayMusicTitle").text(music[musicPlaying[1]][musicPlaying[2]].name);
	}



	musicPlaying[0].ontimeupdate = function(){
			var time = getTime(this.currentTime);
			$(".currentPlayMusicTime").text(time);
			var left = this.currentTime / this.duration * $(".progressBar").width();
			$(".play-btn").css({"left":left});
	}

	$(".progressBar").on("click",function(e){
		musicPlaying[0].currentTime = e.offsetX / $(this).width() * musicPlaying[0].duration;
		$(".play-btn").css({"left":e.offsetX});
	})

	$(".music-control").hover(function(){
		$(this).stop().animate({"bottom":0},100);
	},function(){
		$(this).stop().animate({"bottom":-40},300);
	})
})